package org.foreningsgatan.modular.particles.model;


public class Emitter {
	private Coordinate mCoordinate;
	
	private ParticleTemplate mTemplate;
	
	private double mSpawnRate;

	public Emitter(Coordinate pCoordinate) {
		this.mCoordinate = pCoordinate;
	}
	
	public Coordinate getCoordinate() {
		return mCoordinate;
	}
	
	private Particle spawnParticle() {
		return new Particle(mCoordinate.clone(), mTemplate);
	}
	
	public Particle spawn(int pFrame, int pFrameRate) {
		int vSpawnFrame = (int) (mSpawnRate * pFrameRate);
		
		if (pFrame % vSpawnFrame == 0) {
			return spawnParticle();
		} else {
			return null;
		}
	}
}
